/*
 *    Copyright 2008 Tim Jansen
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.actorsguildframework.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * <p>The Shared annotation is used for message arguments and signals that the argument
 * will always be parsed by reference, so that it is shared by both caller and callee.
 * This is useful if you have an object that can not be Serialized and is not an Actor.
 * </p><p>
 * The arguments passed as <code>@Shared shared</code> <b>must</b> be fully multi-thead-safe, as
 * they will be used in several threads.
 * </p><p>
 * <code>@Shared</code> should be avoided if possible, as shared can only work if caller and callee
 * run in the same VM. Currently ActorsGuild supports only actors in the same VM, and thus 
 * it will always work, but in future versions this may be different.
 * </p>
 * <p>Example:</p>
 * <pre>@Message
 * public AsyncResult<Void> sendMessage(@Shared Socket socket, String msg) throws Exception {
 * 	try {
 * 		String path = HTTPHelper.readHeader(socket.getInputStream());
 *      BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
 *      bw.write(msg);
 *      bw.flush();
 *	}
 *	finally {
 *		socket.close();
 *	}
 *	return noResult();
 * }
 * </pre>
 */
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface Shared {

}
